package com.example.perpetualcalendar.ui.fragment.account;


import android.view.View;

import androidx.annotation.NonNull;
import androidx.lifecycle.Observer;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.example.perpetualcalendar.R;
import com.example.perpetualcalendar.base.BaseFragment;
import com.example.perpetualcalendar.databinding.AccountFragmentBinding;

public class AccountFragment extends BaseFragment<AccountViewModel,AccountFragmentBinding> {

    @Override
    protected void initView() {
        String url = "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fa3.att.hudong.com%2F35%2F34%2F19300001295750130986345801104.jpg&refer=http%3A%2F%2Fa3.att.hudong.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1618388270&t=3b032d5631491d3b85c4260564bd790b";
        RequestOptions options = new RequestOptions()
                .circleCrop();
        Glide.with(getContext()).load(url)
                .apply(options)
                .into(viewBinding.ivAvatar);
        mViewModel.getMName().observe(getViewLifecycleOwner(), s -> {
            viewBinding.textName.setText(s);
        });
        viewBinding.ivAvatar.setOnClickListener(v -> {
            login();
        });
        viewBinding.textName.setOnClickListener(v -> {
            login();
        });
        viewBinding.settingExit.setOnClickListener((v -> {
            mViewModel.exit();
        }));
    }

    private void login() {

    }

    @NonNull
    @Override
    protected Class<AccountViewModel> setViewModel() {
        return AccountViewModel.class;
    }

    @NonNull
    @Override
    protected int setLayout() {
        return R.layout.account_fragment;
    }

}